package iterator;

import java.util.ArrayList;
import java.util.List;

public class StudentGroup implements IterableCollection {
    private final List<String> studentNames = new ArrayList<>();

    public int getSize() {
        return studentNames.size();
    }

    public String get(int index) {
        if (index < 0 || index >= studentNames.size()) {
            return null;
        }
        return studentNames.get(index);
    }


    public void addStudent(String name) {
        studentNames.add(name);
    }

    public void removeStudent(String name) {
        studentNames.remove(name);
    }

    @Override
    public Iterator getAscendIterator() {
        return new AscendIterator(this);
    }

    @Override
    public Iterator getDescendIterator() {
        return new DescendIterator(this);
    }
}
